home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic 4 Database How-To
/
Visual Basic 4 Database - How-to (The Waite Group)(1995).iso
/
query3.fr_
/
query3.fr
Wrap
Text File
|
1995-07-05
|
5KB
|
156 lines
VERSION 4.00
Begin VB.Form Form1
BackColor = &H00C0C0C0&
Caption = "Query Creator"
ClientHeight = 3495
ClientLeft = 435
ClientTop = 1560
ClientWidth = 7605
BeginProperty Font
name = "MS Sans Serif"
charset = 0
weight = 700
size = 8.25
underline = 0 'False
italic = 0 'False
strikethrough = 0 'False
EndProperty
Height = 3900
Left = 375
LinkTopic = "Form1"
ScaleHeight = 3495
ScaleWidth = 7605
Top = 1215
Width = 7725
Begin VB.CommandButton cmdClose
Cancel = -1 'True
Caption = "&Close"
Height = 495
Left = 4380
TabIndex = 7
Top = 2640
Width = 1215
End
Begin VB.CommandButton cmdRefresh
Caption = "&Refresh"
Default = -1 'True
Height = 495
Left = 2160
TabIndex = 6
Top = 2640
Width = 1215
End
Begin VB.Frame grpSelection
BackColor = &H00C0C0C0&
Caption = "Selection"
Height = 1995
Left = 5760
TabIndex = 1
Top = 240
Width = 1515
Begin VB.OptionButton optPublisher
BackColor = &H00C0C0C0&
Caption = "Publisher"
Height = 255
Left = 180
TabIndex = 5
Top = 1560
Width = 1200
End
Begin VB.OptionButton optISBN
BackColor = &H00C0C0C0&
Caption = "ISBN"
Height = 255
Left = 180
TabIndex = 4
Top = 1200
Width = 1200
End
Begin VB.OptionButton optTitle
BackColor = &H00C0C0C0&
Caption = "Title"
Height = 315
Left = 180
TabIndex = 3
Top = 780
Width = 1200
End
Begin VB.OptionButton optAuthor
BackColor = &H00C0C0C0&
Caption = "Author"
Height = 255
Left = 180
TabIndex = 2
Top = 420
Value = -1 'True
Width = 1200
End
End
Begin VB.ListBox List1
Height = 1980
Left = 360
Sorted = -1 'True
TabIndex = 0
Top = 300
Width = 5175
End
End
Attribute VB_Name = "Form1"
Attribute VB_Creatable = False
Attribute VB_Exposed = False
Option Explicit
Const QUERY_NAME = "My Defined Query"
Private Sub cmdClose_Click()
End
End Sub
Private Sub cmdRefresh_Click()
Dim db As DATABASE
Dim dbName As String
Dim qdNew As QueryDef, qdExists As QueryDef
Dim rs As Recordset
Dim sql As String
On Error Resume Next
Screen.MousePointer = 11
' Get the database name and open the database.
dbName = BiblioPath() ' BiblioPath is a function in READINI.BAS
Set db = DBEngine.Workspaces(0).OpenDatabase(dbName)
db.QueryDefs.DELETE QUERY_NAME
If optAuthor Then
sql = "SELECT [Author] FROM [Authors]"
ElseIf optTitle Then
sql = "SELECT [Title] FROM [Titles]"
ElseIf optISBN Then
sql = "SELECT [ISBN] FROM [Titles]"
Else
sql = "SELECT [Name] FROM [Publishers]"
End If
Set qdNew = db.CreateQueryDef(QUERY_NAME, sql)
Set rs = qdNew.OpenRecordset()
qdNew.Close
If rs.RecordCount > 0 Then
FillList rs
Screen.MousePointer = 0
Else
List1.Clear
Screen.MousePointer = 0
MsgBox "The query returned no records", vbExclamation
End If
End Sub
Sub FillList(rs As Recordset)
List1.Clear
rs.MoveFirst
Do
List1.AddItem rs.Fields(0)
rs.MoveNext
Loop While Not rs.EOF
End Sub